# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=widelands
pkgver=1.2
pkgrel=1
pkgdesc="realtime strategy game with emphasis on economy and transport"
url="https://widelands.org"
arch="all !s390x" # nobody will use s390x to place widelands
license="GPL-2.0-or-later"
depends="lua python3"
makedepends="
	asio-dev
	boost-dev
	cmake
	curl-dev
	dbus-dev
	doxygen
	freeglut-dev
	gettext-dev
	glew-dev
	graphviz
	libintl
	libpng-dev
	samurai
	sdl2-dev
	sdl2_image-dev
	sdl2_mixer-dev
	sdl2_net-dev
	sdl2_ttf-dev
	zlib-dev
"
source="https://github.com/widelands/widelands/archive/v$pkgver/widelands-v$pkgver.tar.gz
	0001-link-libintl.patch
	gcc12-no-werror.patch
	sdl-use-x11.patch
	"
subpackages="$pkgname-doc"

build() {
	cmake -B build -G Ninja \
		-Wno-dev \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWL_INSTALL_BASEDIR=/usr \
		-DWL_INSTALL_DATADIR=/usr/share/widelands
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mv "$pkgdir"/usr/games "$pkgdir"/usr/bin

	mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"
	for _file in VERSION ChangeLog CREDITS; do
		mv "$pkgdir/usr/$_file" "$pkgdir"/usr/share/doc/"$pkgname"
	done

	mkdir -p "$pkgdir"/usr/share/licenses/$pkgname
	mv "$pkgdir"/usr/COPYING "$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="
e05812f93defe8b9a3da60e6ba73a65bba47abec3199298f9a778fb42655aba671cb45a2603c2936538de1e0f82892a183ea5e1df15937b9812d369d068fab81  widelands-v1.2.tar.gz
80b3ae89f39635c25e2ff86eb5d281029c5b0a389ede5cdaad70a5a22b3298ba1c74a34fb56c1ae3cfe0681b492603e423e6f4a4f410df44adbbd24ae68bd03c  0001-link-libintl.patch
6c9b93ca12b9bdb13acd49027d672a46fac0c30511167d8ae3adc2ce0d4a2c6457fde22bc4bcf9d093542a306c829afabaa4066d679c95eb9441187789ed3051  gcc12-no-werror.patch
94a69e35f1bb9a83cca26ac96ca100fccad4b8ebbb7c2db1727591b03e73e82ecec940c6dd42fa9d6369bbee2b4b238df4eb879ab084e92e0642b89a37dff2e3  sdl-use-x11.patch
"
